#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int k1,k2,k3;
	for(int i=0;i<n;i++){
	  		cin>>k1>>k2>>k3;
	  		
				for(int m=10;m<101;m++){
						int i=0;
					if(m%3==k1 && m%5==k2 && m%7==k3){
					cout<<"Case"<<" "<<++i<<":"<<m<<endl;
					
					if((m%3!=k1 || m%5!=k2 || m%7!=k3) && (m>=100))
						
							cout<<"Case"<<" "<<++i<<":"<<"NO ANSWER"<<endl;	
										
				}

     		}
	}

	return 0;
}
